import { Entity, Column, Index } from 'typeorm';
import { BaseEntity } from '../../base/entity/base';

/**
 * 商品批次信息
 */
@Entity({ name: 'goods_batch' })
export class GoodsBatchEntity extends BaseEntity {
  @Index()
  @Column({ comment: '商品ID (Oracle)', length: 50 })
  goodsId: string;

  @Column({ comment: '批次号', length: 100, nullable: true })
  batchCode: string;

  @Column({ type: 'datetime', comment: '有效期至', nullable: true })
  valDate: Date;

  @Column({ 
    type: 'decimal', 
    precision: 18, 
    scale: 4, 
    comment: '批次库存 (Oracle)', 
    nullable: true, 
    default: 0 
  })
  stock: number;

  // 可以考虑添加唯一约束，例如 goodsId 和 batchCode 组合
  // @Index(['goodsId', 'batchCode'], { unique: true })
} 